<?php
namespace wechat\controllers;

use Yii;
use yii\base\Event;
use yii\helpers\Url;
use yii\web\Controller;
use framework\helpers\Utils;

/**
 * Site controller
 */
class UncollectedController extends Controller
{
//获取登录用户已投资且仍在竞投中的标
    public function actionBidlist()
    {
    	$session = yii::$app->session;
    	$session->open();
    	if($session->has('sKey'))	//是否有sKey缓存
    	{
    		if ($_REQUEST)
    		{
    			$page = intval($_REQUEST['page']);
				$page_num = intval($_REQUEST['num']);
    			$sKey = $session->get('sKey');
    			$url = PANDA_SERVER.'/queryUncollectedBidList?sKey='.$sKey.'&order=0&curr='.$page.'&num='.$page_num.'&tokenId='.Utils::getTokenId();	//获取用户待收竞标中列表
    			$_result = file_get_contents($url);
    			echo $_result;exit;
    		}
    	}
    	else 
    	{
    		echo '{"msg":"sKey已失效！","status":1001}';
    		exit;
    	}
    }
    
    //获取登录用户已投资且待审核的标
    public function actionAuditlist()
    {
    	$session = yii::$app->session;
    	$session->open();
    	if($session->has('sKey'))	//是否有sKey缓存
    	{
    		if ($_REQUEST)
    		{
    			$page = intval($_REQUEST['page']);
    			$page_num = intval($_REQUEST['num']);
    			$sKey = $session->get('sKey');
    			$url = PANDA_SERVER.'/queryUncollectedAuditList?sKey='.$sKey.'&order=0&curr='.$page.'&num='.$page_num.'&tokenId='.Utils::getTokenId();	//获取用户待收竞标中列表
    			$_result = file_get_contents($url);
    			echo $_result;exit;
    		}
    	}
    	else
    	{
    		echo '{"msg":"sKey已失效！","status":1001}';
    		exit;
    	}
    }
    
    //获取登录用户已投资且正在还款的标。
    public function actionRepaylist()
    {
    	$session = yii::$app->session;
    	$session->open();
    	if($session->has('sKey'))	//是否有sKey缓存
    	{
    		if ($_REQUEST)
    		{
    			$page = intval($_REQUEST['page']);
    			$page_num = intval($_REQUEST['num']);
    			$sKey = $session->get('sKey');
    			$url = PANDA_SERVER.'/queryUncollectedRepayList?sKey='.$sKey.'&order=0&curr='.$page.'&num='.$page_num.'&tokenId='.Utils::getTokenId();	//获取用户待收竞标中列表
    			$_result = file_get_contents($url);
    			echo $_result;exit;
    		}
    	}
    	else
    	{
    		echo '{"msg":"sKey已失效！","status":1001}';
    		exit;
    	}
    }
    
    //获取登录用户已投资且借款人已经还款完毕的标
    public function actionFinishlist()
    {
    	$session = yii::$app->session;
    	$session->open();
    	if($session->has('sKey'))	//是否有sKey缓存
    	{
    		if ($_REQUEST)
    		{
    			$page = intval($_REQUEST['page']);
    			$page_num = intval($_REQUEST['num']);
    			$sKey = $session->get('sKey');
    			$url = PANDA_SERVER.'/queryUncollectedFinishList?sKey='.$sKey.'&order=0&curr='.$page.'&num='.$page_num.'&tokenId='.Utils::getTokenId();	//获取用户待收竞标中列表
    			$_result = file_get_contents($url);
    			echo $_result;exit;
    		}
    	}
    	else
    	{
    		echo '{"msg":"sKey已失效！","status":1001}';
    		exit;
    	}
    }
    
}